/**
 * @file demo page for apiDemo
 * @author renzhonghua
 */
/* globals Page, swan */

Page({
    data: {
        title: '植物识别',
        result:[],
        img:""
    },
uploads: function() {
        var that = this;
        swan.chooseImage({
            count: 1,
            sizeType: ['compressed'],
            success: res => {
                let image =  res.tempFilePaths[0];
                swan.showLoading({
                    title: '努力分析中...',
                    mask: true
                }),
                that.setData({
                        img:image
                }),
                swan.ai.plantClassify({
                    image:image,
                    success(res){
                         swan.hideLoading();
                        that.setData({
                            result:res.result
                        })
                    }
                });
            }
        });
},
});
